//
//  nearTableViewCell.m
//  SXH
//
//  Created by Jack on 15/7/8.
//  Copyright (c) 2015年 lyss. All rights reserved.
//

#import "nearTableViewCell.h"
#import "UIView+AutoLayout.h"
#import "Colours.h"

@implementation nearTableViewCell



- (instancetype)init
{
    self = [super init];
    if (self) {
        self.myImageView = [UIImageView autoLayoutView];
        [self.contentView addSubview:self.myImageView];
        [self.myImageView pinToSuperviewEdges:JRTViewPinTopEdge inset:8.0];
        [self.myImageView pinToSuperviewEdges:JRTViewPinLeftEdge inset:8.0];
        [self.myImageView constrainToSize:CGSizeMake(90, 67)];
        //[self.myImageView pinToSuperviewEdges:JRTViewPinBottomEdge inset:20.0];
        
        self.name = [UILabel autoLayoutView];
        self.name.font = [UIFont systemFontOfSize:15.0];
        [self.contentView addSubview:self.name];
        [self.name pinToSuperviewEdges:JRTViewPinTopEdge inset:6.0];
        [self.name pinAttribute:NSLayoutAttributeLeading toAttribute:NSLayoutAttributeTrailing ofItem:self.myImageView withConstant:6.0];
        
        self.myTagList = [TagListView autoLayoutView];
        
        [self.contentView addSubview:self.myTagList];
        [self.myTagList pinToSuperviewEdges:JRTViewPinTopEdge inset:5.0];
        [self.myTagList pinToSuperviewEdges:JRTViewPinRightEdge inset:5.0];
        UIFont *font = [UIFont systemFontOfSize:12.0];
        
        [self.myTagList constrainToMinimumSize:CGSizeMake(font.pointSize+4, font.pointSize+4)];
        
        [self.myTagList pinAttribute:NSLayoutAttributeLeading toAttribute:NSLayoutAttributeTrailing ofItem:self.name withConstant:5.0];
        
        self.myRating = [RatingBar autoLayoutView];
        [self.contentView addSubview:self.myRating];
        [self.myRating pinAttribute:NSLayoutAttributeLeading toAttribute:NSLayoutAttributeTrailing ofItem:self.myImageView withConstant:8.0];
        [self.myRating pinAttribute:NSLayoutAttributeTop toAttribute:NSLayoutAttributeBottom ofItem:self.name withConstant:5.0];
        self.myRating.isIndicator = YES;
        [self.myRating constrainToSize:CGSizeMake(90, 20)];
        
        self.myTags = [UILabel autoLayoutView];
        self.myTags.textColor = [UIColor black75PercentColor];
        self.myTags.font = [UIFont systemFontOfSize:12.0];
        [self.contentView addSubview:self.myTags];
        [self.myTags pinAttribute:NSLayoutAttributeLeading toAttribute:NSLayoutAttributeTrailing ofItem:self.myImageView withConstant:5.0];
        [self.myTags pinAttribute:NSLayoutAttributeTop toAttribute:NSLayoutAttributeBottom ofItem:self.myRating withConstant:5.0];
        
        self.distance = [UILabel autoLayoutView];
        self.distance.textColor = [UIColor black75PercentColor];
        self.distance.font = [UIFont systemFontOfSize:12.0];
        [self.contentView addSubview:self.distance];
        [self.distance pinToSuperviewEdges:JRTViewPinRightEdge inset:20.0];
        [self.distance pinAttribute:NSLayoutAttributeCenterY toAttribute:NSLayoutAttributeCenterY ofItem:self.myTags];
    }
    return self;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)prepareForReuse{
    
}

@end
